package com.joven.gateway.config;

import org.springframework.cloud.gateway.filter.GatewayFilter;
import org.springframework.cloud.gateway.filter.GatewayFilterChain;
import org.springframework.core.Ordered;
import org.springframework.web.server.ServerWebExchange;
import reactor.core.publisher.Mono;

/**
 * @author joven_wong
 * 2021/6/22 14:35
 * 自定义过滤器
 * gatewayFilter接口是为了实现请求过滤，ordered接口是为了给过滤器设定优先级，值越大级别越低。
 */
public class JovenGatewayFilter implements GatewayFilter , Ordered {
    @Override
    public Mono<Void> filter(ServerWebExchange exchange, GatewayFilterChain chain) {

        System.out.println("这里处理自身逻辑");

        return chain.filter(exchange);
    }

    @Override
    public int getOrder() {
        return 0;
    }
}
